package com.luom.fsp.model.vo;

import cn.hutool.json.JSONUtil;
import com.luom.fsp.model.entity.ProductReview;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 商品评论视图
 *
*/
@Data
public class ProductReviewVO implements Serializable {

    /**
     * 评论id
     */
    private Long id;

    /**
     * 订单id
     */
    private Long orderId;

    /**
     * 用户id
     */
    private Long userId;

    /**
     * 用户名
     */
    private String userName;

    /**
     * 用户头像
     */
    private String userAvatar;

    /**
     * 商品规格id
     */
    private Long skuId;

    /**
     * 商品规格名称
     */
    private String skuName;

    /**
     * 商品id
     */
    private Long productId;

    /**
     * 评价内容
     */
    private String content;

    /**
     * 评分
     */
    private Integer rating;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 修改时间
     */
    private Date updateTime;

    /**
     * 封装类转对象
     *
     * @param productReviewVO
     * @return
     */
    public static ProductReview voToObj(ProductReviewVO productReviewVO) {
        if (productReviewVO == null) {
            return null;
        }
        ProductReview productReview = new ProductReview();
        BeanUtils.copyProperties(productReviewVO, productReview);
        return productReview;
    }

    /**
     * 对象转封装类
     *
     * @param productReview
     * @return
     */
    public static ProductReviewVO objToVo(ProductReview productReview) {
        if (productReview == null) {
            return null;
        }
        ProductReviewVO productReviewVO = new ProductReviewVO();
        BeanUtils.copyProperties(productReview, productReviewVO);
        return productReviewVO;
    }
}
